package com.site.wisdom_construction.controller.iotModule;

import com.alibaba.fastjson.JSONObject;
import com.site.wisdom_construction.responseEntity.OneDataResult;
import com.site.wisdom_construction.responseEntity.Page;
import com.site.wisdom_construction.service.iotModule.TowerCraneBasicService;
import com.site.wisdom_construction.service.iotModule.TowerCraneWarningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author daiyifei
 * @Date 2022/9/1
 * @Description
 */
@Api(tags = "塔吊报警数据接口")
@RestController
@RequestMapping("TowerCraneWarning")
@CrossOrigin
public class TowerCraneWarningController {
    @Autowired
    private TowerCraneWarningService towerCraneWarningService;

    @ApiOperation(value = "根据项目id查询所有报警信息", notes = "必传参数:projectId")
    @PostMapping("/selectTowerCraneWarning")
    public OneDataResult selectTowerCraneWarning(@RequestBody Map map) {
        OneDataResult oneDataResult = new OneDataResult();
        oneDataResult.setData(towerCraneWarningService.findTowerCraneWarning(map));
        return oneDataResult;
    }

    @ApiOperation(value = "根据项目id查询所有报警信息", notes = "必传参数:projectId")
    @PostMapping("/countTower")
    public OneDataResult countTower(@RequestBody Map map) {
        OneDataResult oneDataResult = new OneDataResult();
        JSONObject jsonObject = new JSONObject();

        jsonObject.put("onlineRate","100%");
        jsonObject.put("onlineNumber","7");
        jsonObject.put("alarmNumber",towerCraneWarningService.countTowerCraneWarning(map));
        oneDataResult.setData(jsonObject);
        return oneDataResult;
    }
}
